package org.ciallo.simplemusicplayer.viewmodel;

import android.app.Application;
import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;
import org.ciallo.simplemusicplayer.data.dao.PlayCountDao;
import org.ciallo.simplemusicplayer.data.repository.SongRepository;

import java.util.List;

/**
 * @author Jukomu
 * @Description:
 * @Package: org.ciallo.simplemusicplayer.viewmodel
 * @Project: SimpleMusicPlayer
 * @name: PlayStatsViewModel
 * @Date: 2025/6/13-07:51
 * @Filename: PlayStatsViewModel
 */
public class PlayStatsViewModel extends AndroidViewModel {
    private final SongRepository songRepository;
    public final LiveData<List<PlayCountDao.SongWithPlayCount>> songsWithPlayCounts;

    public PlayStatsViewModel(@NonNull Application application) {
        super(application);
        songRepository = new SongRepository(application);
        songsWithPlayCounts = songRepository.getSongsWithPlayCounts();
    }

    public LiveData<List<PlayCountDao.SongWithPlayCount>> getSongStats() {
        return songsWithPlayCounts;
    }

    public void clearPlayStats() {
        songRepository.clearAllPlayCounts();
    }
}
